home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MYMUD21.ZIP / MMUD21.ZIP / SOURCE / SOURCE.ZIP / NEWWORLD.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-01-21  |  2.5 KB  |  121 lines

  1. {$I COPYRGHT.INC}
  2.  
  3. (*---------------------------------------------------------------------------*
  4.    This unit contains all the routines nessecary to create a new world
  5.  *---------------------------------------------------------------------------*)
  6.  
  7. Unit NewWorld;
  8. interface
  9. Uses Dos,
  10.      MyIO,
  11.      Misc,
  12.      Header;
  13.  
  14. Procedure CreateNewWorld(Name : ComStr);
  15.  
  16. Implementation
  17.  
  18. Procedure CleanRecord(Var Rec: ObjRecord);
  19. Begin
  20. FillChar(Rec,SizeOf(Rec),#00);
  21. With Rec Do
  22.  Begin
  23.  Name       :='';
  24.  Password   :='';
  25.  Key        :='';
  26.  Location   :=-1;
  27.  Contents   :=-1;
  28.  Exits      :=-1;
  29.  Next       :=-1;
  30.  Owner      :=-1;
  31.  Garbage    :=-1;
  32.  End;
  33. End;
  34.  
  35.  
  36. Procedure CreateNewWorld(Name : ComStr);
  37. Var Rec : ObjRecord;
  38.     Out : File of ObjRecord;
  39.     Ply : File of Integer;
  40.     Nr  : Integer;
  41.     Ini : Text;
  42.     Tmp : File;
  43. Begin
  44.   If Pos('.',Name)>0
  45.      Then Name:=Copy(Name,1,Pos('.',Name));
  46.  
  47.   Assign(Out,Name+'.IDX');
  48.   Rewrite(Out);
  49.   If IoResult<>0
  50.      Then Begin
  51.           My_WriteLn('Cannot create IDX file.');
  52.           Halt;
  53.           End;
  54.  
  55.   CleanRecord(Rec);
  56.   With Rec Do
  57.    Begin
  58.    Name     := 'Eden';
  59.    Password := '';
  60.    Key      := '';
  61.    Location := -1;
  62.    Exits    := -1;
  63.    Next     := -1;
  64.    Pennies  :=  0;
  65.    Contents :=  1;
  66.    Owner    :=  1;
  67.    ObjType  := Room_Type;
  68.    End;
  69.   Write(Out,Rec);
  70.  
  71.   CleanRecord(Rec);
  72.   With Rec Do
  73.    Begin
  74.    Name     := 'God';
  75.    Password := 'Potrzebie';
  76.    Key      := '';
  77.    Location :=  0;
  78.    Exits    :=  0;
  79.    Next     := -1;
  80.    Pennies  :=  MaxInt;
  81.    Contents := -1;
  82.    Owner    :=  1;
  83.    ObjType  := Player_Type;
  84.    ObjLevel := God_Level;
  85.    GenFlags := Male_Gender;
  86.    End;
  87.   Write(Out,Rec);
  88.   Close(Out);
  89.  
  90.   If IoResult<>0
  91.      Then My_WriteLn('World creation failed on '+NAME+'.IDX');
  92.  
  93.  
  94.   Assign(Ply,Name+'.PLY');
  95.   Rewrite(Ply);
  96.   Nr:=1;
  97.   Write(Ply,Nr);
  98.   Close(Ply);
  99.   If IoResult<>0
  100.      Then My_WriteLn('World creation failed on '+Name+'.PLY');
  101.  
  102.   Assign(Tmp,Name+'.DAT');
  103.   Rewrite(Tmp);
  104.   Close(Tmp);
  105.   If IoResult<>0
  106.      Then My_WriteLn('World creation failed on '+NAME+'.DAT');
  107.  
  108.   Assign(Ini,Name+'.INI');
  109.   Rewrite(Ini);
  110.   WriteLn(Ini,'<Shared Path>');
  111.   WriteLn(Ini,'<ASCII Editor>');
  112.   Close(Ini);
  113.   If IoResult<>0
  114.      Then;
  115.   My_WriteLn('');
  116.   My_WriteLn('Now edit the '+Name+'.INI file and restart MyMUD again.');
  117.   My_WriteLn('You can login with the name "God" and the password "Potrzebie".');
  118.   Halt;
  119. End;
  120.  
  121. End.